//
//  UserHelper.m
//  TaurusXi
//
//  Created by xicheng on 15/12/12.
//  Copyright © 2015年 xicheng. All rights reserved.
//

#import "UserHelper.h"

@interface UserHelper()

//@property(nonatomic,copy)NSString *userId;

@end

@implementation UserHelper

+ (instancetype)shareUserInstance
{
  static UserHelper *sharedInstance = nil;
  static dispatch_once_t onceToken = 0;
  dispatch_once(&onceToken, ^{
    sharedInstance = [self new];
  });
  return sharedInstance;
}


-(Boolean)isLogin{

  NSString *userId = [self userId];
  if (userId==nil||[[NSString stringWithFormat:@"%@",userId] isEqualToString:@""]) {
    return NO;
  }else{
    return YES;
  }
  
}

-(NSString *)userId{
//  if (_userId==nil || [self.userId isEqualToString:@""]) {
  NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
  NSString  *userId= [userDefaults valueForKey:@"userId"];
    if (userId==nil) {
      userId = @"";
    }
//  }
  return userId;
}

-(void)setUserId:(NSString *)userId{
  NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
  [userDefaults setObject:userId forKey:@"userId"];
  [userDefaults synchronize];
}

@end
